博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
yii 邮箱封装
阅读量:6863 次
发布时间:2019-06-26

本文共 3082 字,大约阅读时间需要 10 分钟。

'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => 'xxx@163.com', 'password' => 'xxx', 'port' => '994', 'encryption' => 'ssl', //ssl tls ]; self::$obj = \Yii::createObject([ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => false, 'transport' => self::$config, ]); } return self::$obj; } public static function send($toEmail, $subject, array $compose) { $user = \Wskm::getUser(); if ($compose) {
        //同时设置2种内容,让用户的偏好自己选择 self::getMailer()->compose( //['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user] //['html' => 'passwordResetToken-html'], ['user' => $user] $compose ); }else{ self::getMailer()->setBody('My amazing body', 'text/html'); self::getMailer()->addPart('My amazing body in plain text', 'text/plain'); } //https://swiftmailer.symfony.com/docs/messages.html //addTo addCc addBcc //$message->setTo(['some@address.tld', 'other@address.tld']); //$message->setCc([ // 'person1@example.org', 'person2@otherdomain.org' => 'Person 2 Name', //]); //->attach(Swift_Attachment::fromPath('my-document.pdf')->setFilename('cool.jpg')) /* // Create the message $message = new Swift_Message('My subject'); // Set the body $message->setBody( '' . ' ' . ' Here is an image Image' . ' Rest of message' . ' ' . '', 'text/html' // Mark the content-type as HTML ); */ /* * 验证 use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Validation\RFCValidation; $validator = new EmailValidator(); $validator->isValid("example@example.com", new RFCValidation()); */ /* * 加密 $smimeSigner = new Swift_Signers_SMimeSigner(); $smimeSigner->setSignCertificate('/path/to/certificate.pem', ['/path/to/private-key.pem', 'passphrase']); $message->attachSigner($smimeSigner); */ /* * 回执 $MESSAGE->setReadReceiptTo('你@地址。 TLD '); */ /** * ->setCharset('iso-8859-2'); 编码 * ->setPriority(2); 设置优先级,1-5 */ return self::getMailer()->compose( //['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user] ['html' => 'passwordResetToken-html'], ['user' => $user] ) ->setFrom([ self::$config['username'] => 'test robot']) ->setTo($toEmail) ->setSubject($subject) ->send(); }}

 

转载地址:http://ftqyl.baihongyu.com/

你可能感兴趣的文章
python 一些有趣的模块
查看>>
haproxy实现均衡负载(linux)
查看>>
[Unity 3D]摄像机Clear Flags和Culling Mask属性用途详解
查看>>
实战阿里云-实战Fail2Ban之v0.9.3
查看>>
Net设计模式实例之单例模式( Singleton Pattern)(2
查看>>
RedHat9上oracle9.2的安装
查看>>
看黄仁勋的不跟随style NVIDIA在CES2018上继续说自动驾驶那些事儿
查看>>
samba报错:session setup failed: NT_STATUS_LOGON_FAILURE 解决
查看>>
快乐识记CSDN一些信息
查看>>
Java后端工程师学习大纲
查看>>
Android6.0动态获取权限
查看>>
Spring 中的 classpath*: 与 classpath: 通配符
查看>>
CCNP-35 BGP 5
查看>>
XML file
查看>>
快速构建datatable
查看>>
Android使用DownloadManager实现文件下载
查看>>
oracle编译存储过程提示表或视图不存在的问题分析
查看>>
基于OpenCV实现的Android移动端口红AR
查看>>
提升 IE7 的访问速度
查看>>
积少成多Flash(5) - ActionScript 3.0 实例之闹钟(自定义事件, 画图, 动画)
查看>>